package com.cloudpark.common.util;

public class MessageUtil {

    public static String info(int code, String text) {
        StringBuffer buf = new StringBuffer();
        buf.append("{");
        buf.append("\"code\":").append(code).append(", \"text\":\"").append(text).append("\"");
        buf.append("}");
        return buf.toString();
    }

    public static String info(int code, String text, boolean bool) {
        StringBuffer buf = new StringBuffer();
        buf.append("{");
        buf.append("\"code\":").append(code).append(", \"text\":\"").append(text).append("\"").append(", \"speak\":\"")
                .append(bool).append("\"");
        buf.append("}");
        return buf.toString();
    }

    public static String success() {
        StringBuffer buf = new StringBuffer();
        buf.append("{");
        buf.append("\"code\":1");
        buf.append("}");
        return buf.toString();
    }
    
    public static String success(String text) {
        StringBuffer buf = new StringBuffer();
        buf.append("{");
        buf.append("\"code\":1").append(", \"text\":\"").append(text).append("\"");
        buf.append("}");
        return buf.toString();
    }

    public static String success(String text, String remark) {
        StringBuffer buf = new StringBuffer();
        buf.append("{");
        buf.append("\"code\":1").append(", \"text\":\"").append(text).append("\"").append(", \"remark\":\"")
                .append(remark).append("\"");
        buf.append("}");
        return buf.toString();
    }

    public static String error(String text) {
        StringBuffer buf = new StringBuffer();
        buf.append("{");
        buf.append("\"code\":-1").append(", \"text\":\"").append(text).append("\"");
        buf.append("}");
        return buf.toString();
    }
    
    public static String zero() {
        StringBuffer buf = new StringBuffer();
        buf.append("{");
        buf.append("\"code\":0");
        buf.append("}");
        return buf.toString();
    }
}
